function pdfPrint(url, fileName) {
	$('#printForm').attr('action', url)
	$('#printGridId').val(centerItem.getSelection()[0].id)
	$('#jasperFileName').val(fileName)
	printForm.submit()

}

function wordPrint(url, fileName) {
	$('#printForm').attr('action', url)
	$('#templateFile').val(fileName)
	printForm.submit()

}
  
fun  ction gridToExcel(obj   ) {
	var grid = obj ? obj : centerItem
	var lastOptions = grid.getStore().lastOptions;
	// console.log(lastOptions)
	var lastParams = Ext.clone(lastOptions.params);
	if (lastParams == null) {
		lastParams = {}
	}

	// console.log(grid.columns[0].config.text)
	console.log(lastOptions.sorters)
	lastParams.limit = maxGridPageSize;
	lastParams.page = 1;
	lastParams.start = 0;
	var colsName = []
	var colsData = []
	for (o in grid.columns) {
		if (grid.columns[o].printable == null
				|| grid.columns[o].printable == true) {
			colsName.push(grid.columns[o].config.text)
			colsData.push(grid.columns[o].dataIndex)
		}
	}
	lastParams.colsName = colsName.join(",");
	lastParams.colsData = colsData.join(",");
	var printStore = Ext.create('Ext.data.Store', {
		remoteSort : true,
		remoteFilter : true,
		sorters : lastOptions.sorters,
		proxy : {
			type : 'ajax',
			url : grid.getStore().proxy.url,
			reader : {
				type : 'json',
				root : 'results',
				totalProperty : 'total'
			}
		},
		listeners : {
			load : function() {
				window.open('../base/downloadexcel')
			}
		}
	});

	printStore.reload({
		params : lastParams
	});

}

function ajaxPost(url, para, func, message) {
	Ext.getBody().mask("请稍等...");
	Ext.Ajax.request({
		url : url,
		params : para,
		success : function(response) {
			var res = Ext.JSON.decode(response.responseText)
			Ext.getBody().unmask()
			if (res.message != null) {
				messageAlert(res.message)
			} else {
				toastSuccess()
			}
			func(response)
		}
	});
}

function submitForm(func, pForm) {
	Ext.getBody().mask(SAVE_WAITING_MESSAGE);
	var form = pForm ? pForm : centerItem
	if (form.isValid()) {
		form.submit({
			submitEmptyText : false,
			success : function(form, action) {
				Ext.getBody().unmask()
				if (action.result.message != null) {
					messageAlert(action.result.message)
				} else {
					toastSuccess()
					func()
				}
			},
			failure : function(form, action) {
				Ext.getBody().unmask();
				messageAlert(action.result)
			}
		});
	}
}

function goModule(url) {
	var jsPath = url
	var pathPara = ""
	if (jsPath.indexOf('?') != -1) {
		pathPara = "/" + jsPath.substring(jsPath.indexOf('?') + 1)
		jsPath = jsPath.substring(0, jsPath.indexOf('?'))
	}
	var jsPath = jsPath.replace("/", "%")
	window.location = "index.html#" + jsPath + pathPara
}

function runModule(jsPath) {
	Ext.Ajax.request({
		url : "js/" + jsPath + ".js",
		params : {},
		success : function(response) {
			// console.log(response.responseText)
			eval(response.responseText)
		}
	});
}

function toastSuccess(message) {
	Ext.toast({
		html : message ? message : '操作成功！',
		title : '系统提示',
		width : 200,
		align : 't'
	});
}

function messageAlert(message) {
	Ext.Msg.alert('操作失败,错误原因如下:', message)
}

function actionConfirm(func, message) {
	Ext.Msg.confirm('操作提示', message, function(e) {
		if (e == 'yes') {
			func()
		}
	});
}

function saveConfirm(func, message) {
	actionConfirm(func, message ? message : "是否确定?")
}

function delConfirm(func) {
	Ext.Msg.confirm('刪除确认', '是否刪除?', function(e) {
		if (e == 'yes') {
			func()
		}
	});
}

var DEL_WAITING_MESSAGE = '正在刪除，请稍等...'
var SAVE_WAITING_MESSAGE = '正在保存，请稍等...'

var comboAllCode = '_ALL_'
var comboAllLable = '全部'
var comboAllData = {
	id : comboAllCode,
	text : comboAllLable
}

var storeData = [ comboAllData, {
	id : 'MALE',
	text : '男'
}, {
	id : 'FEMALE',
	text : '女'
} ]
var sexAllStore = Ext.create('Ext.data.Store', {
	data : storeData,
	autoLoad : true
});
storeData = storeData.slice(1)
var sexStore = Ext.create('Ext.data.Store', {
	data : storeData,
	autoLoad : true
});

storeData = [ comboAllData, {
	id : 'ON_JOB',
	text : '在职'
}, {
	id : 'RETIRE',
	text : '离退'
} ]

var stateAllStore = Ext.create('Ext.data.Store', {
	data : storeData,
	autoLoad : true
});
storeData = storeData.slice(1)
var stateStore = Ext.create('Ext.data.Store', {
	data : storeData,
	autoLoad : true
});

storeData = [ comboAllData, {
	id : 'IN',
	text : '入库'
}, {
	id : 'OUT',
	text : '出库'
} ]

var actionTypeAllStore = Ext.create('Ext.data.Store', {
	data : storeData,
	autoLoad : true
});
storeData = storeData.slice(1)
var actionTypeStore = Ext.create('Ext.data.Store', {
	data : storeData,
	autoLoad : true
});

var gridPageSize = 10
var maxGridPageSize = 1000000
var gridHeight = '100%' // '100%'
var gridWidth = '100%'

var defaultNotBlankLabel = '<font style="color:red">*</font>'
var viewMode = false
var searchId = null
var notBlankLabel = defaultNotBlankLabel

var readOnlyCss = 'background:#E6E6E6' // ,fieldStyle:((viewMode||searchId)?'background:#E6E6E6':'')
